#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int numRabbits(vector<int>& answers) {
    int res = 0;
    sort(answers.begin(), answers.end());
    int last = answers[0], cnt = 0;
    for (auto x : answers)
    {
        if (x == last)
        {
            if (cnt)
                cnt--;
            else
            {
                res += x + 1;
                last = x;
                cnt = x;
            }
        }
        else
        {
            res += x + 1;
            last = x;
            cnt = x;
        }
    }
    return res;
}